<?php
/**
 * Created by PhpStorm.
 * User: liuxiaojie
 * Date: 2019-02-24
 * Time: 11:43
 */

namespace app\shell\controller;

use think\Controller;

class Express extends Controller
{

    public $key = "27292cdf6f2419f068c37923a06be2a9";

    function index()
    {
        $url = "http://v.juhe.cn/exp/com?key=".$this->key;

        $data = curl($url);
//        file_put_contents("1.txt", $data);
//        $data = file_get_contents('1.txt');
        $data = json_decode($data, true);

        $post = [];
        foreach ($data['result'] as $v){
            $post[] = [
                'express'=> $v['com'],
                'type'=> $v['no']
            ];
        }

        db('express')->insertAll($post);
    }

}